<template>
    <div>
        <h2>NavBar</h2>
        <button @click="getParentAndRoot">获取父组件和根组件</button>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                message: 'hello'
            }
        },
        methods: {
            sayHello() {
                console.log('hello again');
            },
            getParentAndRoot() {
                console.log(this.$parent);
                console.log(this.$root);
            }
        }
    }
</script>

<style scoped>

</style>